/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.shsc.dao.implementations;

import com.bionic.shsc.dao.interfaces.ISolutionDAO;
import com.bionic.shsc.entities.ProblemData;
import com.bionic.shsc.entities.SolutionData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ant
 */
public class MySQLSolution extends QueryExecutor implements ISolutionDAO {

    @Override
    public ArrayList<SolutionData> getSolutionList(String aProblemList) {
          ArrayList<SolutionData> solutions = new   ArrayList<SolutionData>();
        String querySQL = "SELECT `solution`.`solution_id`,    `solution`.`text`,    `solution`.`problem_id`  FROM `shsc`.`solution`\n" +
         "where `solution`.`problem_id` in (?) ;";
        try {
            PreparedStatement pstmt = query.getConnection().prepareStatement(querySQL);
            pstmt.setString(1, aProblemList);
            ResultSet results = pstmt.executeQuery();
            while (results.next()) {
                SolutionData p = new SolutionData();
                p.setProblemID(results.getInt("problem_id"));
                p.setSolutionID(results.getInt("solution_id"));
                p.setText(results.getString("text"));
             solutions.add(p);
            }
            return solutions;
        } catch (SQLException ex) {
            Logger.getLogger(MySQLQuery.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } }
    
}
